package com.hualan.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.entity.Artical;
import com.hualan.sfzy.entity.Cspi;
import com.hualan.sfzy.mapper.ArticalMapper;
import com.hualan.sfzy.service.ArticalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class ArticalServiceImpl implements ArticalService {

    @Autowired
    private ArticalMapper articalMapper;

    @Override
    public int add(Artical entity) {
        return 0;
    }

    @Override
    public int addSelective(Artical artical) {
        return articalMapper.insert(artical);
    }


    @Override
    public int edit(Artical entity) {
        return articalMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return articalMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return articalMapper.deleteBatch(ids);
    }

    @Override
    public List<Artical> find() {
        return Collections.emptyList();
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, Artical entity) {
        return Collections.emptyMap();
    }

    @Override
    public List<Artical> findAll() {
        return articalMapper.selectArticalAndPsycCounselorAll();
    }

    @Override
    public Map<String, Object> findArticalAndCounselorAndAricalClassificationPage(Integer pageNum, Integer pageSize, Artical artical) {
        PageHelper.startPage(pageNum,pageSize);
        List<Artical> list = articalMapper.fuzzySelectArticalAndPsycCounselorAndArticleClassificationSelective(artical);
        PageInfo<Artical> pageInfo = new PageInfo<>(list);
        Map<String, Object> map = new HashMap<>();
        map.put("pageInfo", pageInfo);
        return map;
    }


    @Override
    public Artical findById(Integer id) {
        return articalMapper.selectById(id);
    }
}
